package angle;
import java.util.ArrayList;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: MENG
 * Date: 2022-06-30
 * Time: 21:46
 */
public class YangHuiAngle {
    public List<List<Integer>> yangHui(int numRows){
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> row1 = new ArrayList<>();

        ret.add(row1);//把第一行的list顺序表加入到最大的顺序表中

        for (int i = 1; i < numRows; i++) {
            List<Integer> curRow = new ArrayList<>();
            curRow.add(1);

            List<Integer> preRow = ret.get(i-1);//获取i的上一行（ret中存储的就是每行的数据）
            for (int j = 1; j < i; j++) {
                int num = preRow.get(j) + preRow.get(j-1);
                curRow.add(num);
            }
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }
}
